package com.seari.main;

import java.util.Properties;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.seari.Utils.MiscTools;
import com.seari.commonutils.redis.JedisUtilProxy;

@Component
@Order(value = 1)
public class StartUpClass implements ApplicationRunner{
	
	protected static Logger logger = LoggerFactory.getLogger(StartUpClass.class);
	public static Properties config; 
	static String configFilePath = "config.cfg";
	public static String envConfig;
	//人员信息配置
	public static String flowData; //车站客流
	public static String StatisticsData; //周边客流
	public static String regionalData; //区域客流
	public static String hourAnalysis; //工时分析
	public static String fileStudy; //文件学习
	//首页配置
	public static String monitor; //首页温湿度
	public static String systemOverview; //系统总览
	public static String operationMode; //系统运行模式
	public static String operationalEvent; //车站运营事件
	public static String trend; //客流趋势
	public static String density; //区域客流密度
	public static String personInfo; //人员信息
	public static String workInfo; //任务信息
	//设备配置
	public static String faultMonitoringData; //设备总览
	public static String faultStatisticsData; //故障统计
	public static String faultTrendData; //故障趋势
	public static String energyRatio;//能耗占比
	public static String EnergyMonitorData; //能耗统计
	public static String EnergyTrendData; //能耗趋势
	@Override
	public void run(ApplicationArguments args) throws Exception {
		System.out.println("start up class loading...");
        JedisUtilProxy.initJedisPoolUtil("127.0.0.1", 6379);
        init();
	}
	
	
    public void init(){
    	try
		{
			config = MiscTools.loadConfig(configFilePath);
			envConfig = config.getProperty("EnvConfig_now");
			//人员信息配置
			flowData = config.getProperty("flowData");
			StatisticsData = config.getProperty("StatisticsData");
			regionalData = config.getProperty("regionalData");
			hourAnalysis = config.getProperty("hourAnalysis");
			fileStudy = config.getProperty("fileStudy");
			//首页配置
			monitor = config.getProperty("monitor");
			systemOverview = config.getProperty("systemOverview");
			operationMode = config.getProperty("operationMode");
			operationalEvent = config.getProperty("operationalEvent");
			trend = config.getProperty("trend");
			density = config.getProperty("density");
			personInfo = config.getProperty("personInfo");
			workInfo = config.getProperty("workInfo");
			//设备配置
			faultMonitoringData = config.getProperty("faultMonitoringData");
			faultStatisticsData = config.getProperty("faultStatisticsData");
			faultTrendData = config.getProperty("faultTrendData");
			energyRatio = config.getProperty("energyRatio");
			EnergyMonitorData = config.getProperty("EnergyMonitorData");
			EnergyTrendData = config.getProperty("EnergyTrendData");
		} catch (Exception e)
		{
			// TODO: handle exception
			logger.warn(e.getMessage());
		}
    	logger.info("read config file complete");
    }
}
